package com.net.shop.car.manager.api.volley.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.net.shop.car.manager.api.model.Goods;
import com.net.shop.car.manager.api.volley.Response;
import com.net.shop.car.manager.utils.Constants;
import com.net.shop.car.manager.utils.LogUtils;
import com.net.shop.car.manager.utils.StringUtils;

/**
 * @author Deve
 *
 */
public class ServiceOtherGoodsPageResponse extends Response {
	
	private List<Goods> serviceTwoGoods = new ArrayList<Goods>();

	/**
	 * @param type
	 */
	public ServiceOtherGoodsPageResponse() {
		super(Constants.SELLER_INFO_PAGE);
		// TODO Auto-generated constructor stub
	}

	@Override
	public String getContentTag() {
		// TODO Auto-generated method stub
		return "servicetwo";
	}
	
	@Override
	public void parseContent(String content) {
		try {
			JSONArray jsonArray = new JSONArray(content);
			for (int i = 0; i < jsonArray.length(); i++) {
				JSONObject object = jsonArray.getJSONObject(i);
				Goods goods = new Goods();
				goods.setCheapPrice(StringUtils.filterMoneyNull(object.getString("CHEAP_PRICE")));
				goods.setGoodId(StringUtils.filterNull(object.getString("ID")));
				goods.setGoodName(StringUtils.filterNull(object.getString("GOOD_NAME")));
				goods.setSupportVB(StringUtils.filterBoolNull(object.getString("IS_VB")));
				goods.setPrice(StringUtils.filterMoneyNull(object.getString("PRICE")));
				serviceTwoGoods.add(goods);
			}
		} catch (JSONException e) {
			LogUtils.e(e.getMessage());
		}
	}
	
	public List<Goods> getServiceTwoGoods() {
		return serviceTwoGoods;
	}
}
